import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { TypeOrmModule } from '@nestjs/typeorm';
import { BullModule } from '@nestjs/bull';
import { Connection } from 'typeorm';

import { UserEntity } from './api/user/user.entity';
import { UserModule } from './api/user/user.module';
import { AuthController } from './auth/auth.controller';
import { AuthService } from './auth/auth.service';
import { JwtStrategy } from './auth/jwt.strategy';
import { ArticleModule } from './api/article/article.module';
import { AudioModule } from './api/audio/audio.module';

@Module({
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    TypeOrmModule.forRoot({
      "type": "mysql",
      "host": "localhost",
      "port": 3306,
      "username": "root",
      "password": "root",
      "database": "blog",
      "entities": [UserEntity],
      "synchronize": true,
      "autoLoadEntities": true
    }),
    BullModule.registerQueue({
      name: 'audio',
      redis: {
        host: 'localhost',
        port: 6379
      }
    }),
    UserModule,
    PassportModule,
    ArticleModule,
    AudioModule
  ],
  controllers: [AuthController],
  providers: [AuthService,JwtStrategy],
})
export class AppModule {
  constructor(private readonly connection: Connection){}
}
